Execution context and scope are not the same thing. Scope determines where variables are accessible, while execution context manages the environment in which code runs and memory is allocated.
When a function runs, an Execution Context is created. One of the first things that context does is look at the Scope (the script) to figure out which variables it's allowed to touch.
The scope is function-based. Scope belongs to the variable access of a function. There are only two scopes in JavaScript — global and function scope.
Scope is Static (Lexical). It is determined by where you write your code in the file. Once you save your .js file, the scope is set in stone.
It defines the visibility and accessibility of variables.
It follows the 'Scope Chain.' A child function can see variables in its parent’s scope, but a parent cannot see into a child’s scope.
It is defined at author-time.
Execution context is object-based. Execution context is an abstract concept that holds information about the environment where the current code is being executed. A context of a function is the value of the this keyword for that function
Execution Context is Dynamic. It is created by the JavaScript engine only when a function is actually called (invoked).
It is the environment that handles the 'work.' It contains the this keyword, the variable object, and a reference to the outer scope.
It is created at runtime and is destroyed once the function finishes running.